package com.xtayfjpk.security.jsse;

import java.security.cert.X509Certificate;

import javax.net.ssl.HandshakeCompletedEvent;
import javax.net.ssl.HandshakeCompletedListener;

public class SimpleHandleShakeListener implements HandshakeCompletedListener {
	private String ident;
	
	public SimpleHandleShakeListener(String ident) {
		this.ident = ident;
	}
	
	@Override
	public void handshakeCompleted(HandshakeCompletedEvent event) {
		try {
			X509Certificate certificate = (X509Certificate) event.getPeerCertificates()[0];
			System.out.println(event.getPeerCertificates().length);
			String peer = certificate.getSubjectDN().getName();
			System.out.println(ident + ":Request from " + peer);
		} catch(Exception e) {
			e.printStackTrace();
		}

	}

}
